package com.samphanie.security.validation;

import com.samphanie.security.validation.service.RedisValidateCodeServiceImpl;
import com.samphanie.security.validation.service.ValidateCodeMapper;
import com.samphanie.security.validation.sms.ISmsCodeSenderService;
import com.samphanie.security.validation.sms.impl.DefaultSmsCodeSenderImpl;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 验证码生成器
 *
 * @author ZSY
 * @email 1451691457@qq.com
 */
@Configuration
public class ValidateCodeBeanConfig {

    @Bean
    @ConditionalOnMissingBean(ISmsCodeSenderService.class)
    public ISmsCodeSenderService smsCodeSenderService() {
        return new DefaultSmsCodeSenderImpl();
    }

    @Bean
    @ConditionalOnMissingBean(ValidateCodeMapper.class)
    public ValidateCodeMapper validateCodeMapper() {
        return new RedisValidateCodeServiceImpl();
    }

}
